package org.alerve.android.resourcebuilder;

import org.alerve.android.resourcebuilder.modules.DefaultResourceNameParser;

public @interface ResourceNameParser {

	/**
	 * 
	 * Interface used to parse the name of a resource into the relevant name
	 * used in the xml files. Implementations must provide only the default
	 * constructor if any.
	 * 
	 * @author pabs87@gmail.com
	 * 
	 */
	public interface IParser {

		public String parse(String name);

	}

	public static class Parser {
		public static IParser getParser(ResourceNameParser annotation) {
			if (annotation == null) {
				return new DefaultResourceNameParser();
			} else {
				try {
					return annotation.value().newInstance();
				} catch (Exception e) {
					return getParser(null);
				}
			}
		}
	}

	public Class<? extends IParser> value() default DefaultResourceNameParser.class;

}
